package JDBC;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collection;

public class SQLselect {
    public void func(String name, Connection connection)throws SQLException{
        String sql="select id from student where name = ?";
        PreparedStatement statement=connection.prepareStatement(sql);
        statement.setString(1,name);
        ResultSet n=statement.executeQuery();
        while(n.next()){
            int ret=n.getInt("id");
            System.out.print(ret);
        }
        System.out.println();
        statement.close();
    }
}
